package gerror

import jsoniter "github.com/json-iterator/go"

type JsonerAPI interface {
	// Marshal adapts to json/encoding Marshal API
	// Refer to https://godoc.org/encoding/json#Marshal for more information
	Marshal(v any) ([]byte, error)
	// Unmarshal adapts to json/encoding Unmarshal API
	// Refer to https://godoc.org/encoding/json#Unmarshal for more information
	Unmarshal(data []byte, v any) error
}

var packageJsoner JsonerAPI = jsoniter.ConfigCompatibleWithStandardLibrary

func SetJsoner(lib JsonerAPI) {
	packageJsoner = lib
}
